<?php 
class AlbumComment extends ARAlbumComment {

	
	public function rules(){
		$user = Yii::app()->user;
		
		$rules[] = array('aid, pid', 'numerical');
		$rules[] = array('comment', 'required');
		$rules[] = array('aid', 'required', 'on' => 'album');
		$rules[] = array('pid', 'required', 'on' => 'photo');
		if(!$user->isGuest){
			$rules[] = array ('author', 'default', 'value' => $user->name, 'setOnEmpty' => false);
			$rules[] = array ('authorId', 'default', 'value' => $user->id, 'setOnEmpty' => false);
		}else{
			$rules[] = array ('author', 'required');
			$rules[] = array ('author', 'length', 'min' => 4, 'max' => 15);
			$rules[] = array ('author', 'filter', 'filter' => 'htmlspecialchars', 'on' => 'album');
		}
		$rules[] = array('comment', 'length', 'min' => 4, 'max' => 65535);
		$rules[] = array('ip', 'default', 'value' => Yii::app()->request->userHostAddress, 'setOnEmpty' => false);
		$rules[] = array('lastUpdateTime', 'default', 'value' => BEGIN_TIME, 'setOnEmpty' => false);
		return $rules;
	}
	
	public function attributeLabels(){
		static $labels;
		return empty( $labels ) ? $labels = array(
			'author' => Yii::t('album', '昵称'),
			'comment' => Yii::t('album', '评论')
		) : $labels;
	}
}

?>